window: tie focus to surface state changes
authorMatthias Clasen <mclasen@redhat.com>
Thu, 2 Apr 2020 21:21:01 +0000 (17:21 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 2 Apr 2020 21:21:01 +0000 (17:21 -0400)
We don't get a focus-out on the event controller, when
the surface is losing keyboard focus, since we are not
moving our focus to some other widget, so we are never
unsetting the mnemonics-visible property. Do that in
response to surface state changes instead.

gtk/gtkwindow.c

index d57810aa438002ef5a8bafcaaf987a01f6eca239..204f34d4bebae94799fdcbb1159cda6da4b8365e 100644 (file)
@@ -5088,7 +5088,16 @@ surface_state_changed (GtkWidget *widget)
   priv->state = new_surface_state;
 
   if (changed_mask & GDK_SURFACE_STATE_FOCUSED)
-    ensure_state_flag_backdrop (widget);
+    {
+      gboolean focused = new_surface_state & GDK_SURFACE_STATE_FOCUSED;
+
+      ensure_state_flag_backdrop (widget);
+
+      _gtk_window_set_is_active (window, focused);
+
+      if (!focused)
+        gtk_window_set_mnemonics_visible (window, FALSE);
+    }
 
   if (changed_mask & GDK_SURFACE_STATE_FULLSCREEN)
     {